package com.flannery.utilslibrary;

import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;

import java.lang.ref.WeakReference;

/**
 * Created by Administrator on 2016/12/18.
 */

public final class ActivityUtils {

    /***
     * must be set beforfe setContentView();
     *
     * @param act
     */
    public static void setFullScreen(Activity act) {
        WeakReference<Activity> activityWeakReference = new WeakReference<>(act);
        activityWeakReference.get().requestWindowFeature(Window.FEATURE_NO_TITLE);
        activityWeakReference.get().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    public static void setFullScreenWithtitle(Activity act) {
        WeakReference<Activity> activityWeakReference = new WeakReference<>(act);
//        activityWeakReference.get().requestWindowFeature(Window.FEATURE_NO_TITLE);
        activityWeakReference.get().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    public static void setNoOverridePendingTransition(Activity act) {
        WeakReference<Activity> activityWeakReference = new WeakReference<>(act);
        activityWeakReference.get().overridePendingTransition(0, 0);
    }
}
